from ..common.mysql_operate import MySQLDatabase
from ..config.mysql_config import DB_CONFIG
import sys, json

def main(arg_id):
    # 初始化数据库连接
    db = MySQLDatabase(DB_CONFIG)

    # 查询操作示例
    users = db.execute_query(f"SELECT * FROM tb_user where id = {arg_id}")
    user_list = [user for user in users]
    print(json.dumps(user_list))
    # 关闭连接
    db.close()

if __name__ == "__main__":
    arg_id = sys.argv[1]
    main(arg_id)